package com.lez.flowpractice2.db

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import kotlinx.coroutines.flow.Flow

@Dao
interface UserDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)   //冲突策略，如果插入的user id一样，会替换
    suspend fun insert(user:User)

    @Query("SELECT *FROM user")
    fun getAll(): Flow<List<User>>
}